package com.wxj.likou.date250124;

import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.wxj.likou.domain.Person;
//import com.wxj.likou.domain.Person;

public class TestJson {
    static Person p = new Person("sdfasdfadsfadddddddddddddddddddddddddddddddddddddddddddaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa","sdfasdfadsfadddddddddddddddddddddddddddddddddddddddddddaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa","sdfasdfadsfadddddddddddddddddddddddddddddddddddddddddddaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");

    public static void main(String[] args) throws JsonProcessingException {
        for (int i = 0; i < 20; i++) {
//            testJackson(); // 207
            testGson();
//            testFastjson();
//        System.out.println("gson:"+testGson());
//        System.out.println("Fastjson:"+testFastjson());
        }



    }

    public static long testJackson () throws JsonProcessingException {
        long start = System.currentTimeMillis();
        ObjectMapper objectMapper = new ObjectMapper();
        objectMapper.writeValueAsString(p);
        long end = System.currentTimeMillis();
        System.out.println("Jackson---"+ (end - start));
        return end - start;
    }

    public static long testFastjson () {
        long start = System.currentTimeMillis();
        JSONObject.toJSONString(p);
        long end = System.currentTimeMillis();
        System.out.println("Fastjson---"+ (end - start));
        return end - start;
    }

    public static long testGson () {
        long start = System.currentTimeMillis();
        Gson gson = new Gson();
        gson.toJson(p);
        long end = System.currentTimeMillis();
        System.out.println("Gson---"+ (end - start));

        return end - start;
    }
}
